/**
 * @param {string} start
 * @param {string} end
 * @param {string[]} bank
 * @return {number}
 */
 var minMutation = function(start, end, bank) {
  const diff = (a, b) => {
      const l = a.length;
      let c = 0;
      for(let i = 0;i < l; i++) {
          a[i] === b[i] || c++;
      }
      return c;
  }
  // console.log(diff("AACCGGTT", "AACCGGAA"))
  const visited = new Array(bank.length).fill(-1);
  let c = 1;
  let stack = [start];
  while(stack.length !== 0) {
      const next = [];
      while(stack.length !== 0) {
          const n = stack.pop();
          for(let i = 0; i < bank.length; i++) {
              if(visited[i] === -1) {
                  const d = diff(n, bank[i]);
                  if(d === 1) {
                      if (bank[i] == end) {
                          return c;
                      }
                      visited[i] = c;
                      next.push(bank[i]);
                  }
              }
          }
      }
      c++;
      stack = next;
  }
  return -1;
};